﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///ResponseHelper 的摘要说明
/// </summary>
public class ResponseHelper
{
    public static void DownloadFile(HttpResponse response, System.IO.FileInfo file, string newFileName)
    {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ContentType = "application/octet-stream";
        HttpContext.Current.Response.ClearHeaders();
        HttpContext.Current.Response.ClearContent();
        HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + newFileName+file.Extension);
        HttpContext.Current.Response.AppendHeader("Content-Length", file.Length.ToString());
        HttpContext.Current.Response.WriteFile(file.FullName);
        HttpContext.Current.Response.Flush();
        HttpContext.Current.Response.End();
    }
}
